require(["config"], function() {
    require(["jquery", "header"], function($) {
        function Register() {
            this.addListener();
        }

        $.extend(Register.prototype, {
            addListener: function() {
                $(".zhuce").on("click", $.proxy(this.registerHandler, this));
            },
            registerHandler: function() {
                var data = $(".biao").serialize();
                var url = "http://localhost:921/incake/api/register.php";
                $.post(url, data, this.regSuccessHandler, "json");
                return false;
            },
            regSuccessHandler: function(data) {
                if (data.res_code === 1) {
                    location = "/html/login.html";
                } else {
                    $(".reg-error").removeClass("hidden").text("注册失败：" + data.res_message);
                }
            }
        });
        new Register();
    });
});